﻿using System.Globalization;
using System.Collections.Generic;

namespace Silverlight.InputCtrl
{
    /// <summary>
    /// Culture Helpper
    /// </summary>
    internal static class CultureHelper
    {
        /// <summary>
        /// Return Date Separator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Date Separator</returns>
        public static string GetDateplaceholder(CultureInfo Culture)
        {
            // bug DateSeparator is private property
            // Workarround
            string aux = Culture.DateTimeFormat.ShortDatePattern;
            string result = aux.Substring(0, 1);
            for (int i = 0; i < aux.Length; i++)
            {
                if (result != aux.Substring(i,1))
                {
                    result = aux.Substring(i, 1);
                    break;
                }
            }
            return result;
        }

        /// <summary>
        /// Return Time Separator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Time Separator</returns>
        public static string GetTimeplaceholder(CultureInfo Culture)
        {
            // bug TimeSeparator is private property
            // Workarround 
            string aux = Culture.DateTimeFormat.ShortTimePattern;
            string result = aux.Substring(0, 1);
            for (int i = 0; i < aux.Length; i++)
            {
                if (result != aux.Substring(i, 1))
                {
                    result = aux.Substring(i, 1);
                    break;
                }
            }
            return result;
        }

        /// <summary>
        /// Return AM/PM Indicator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>Array String with symbols AM/PM</returns>
        public static string[] GetAMPMplaceholders(CultureInfo Culture)
        {
            List<string> result = new List<string>();
            result.Add(Culture.DateTimeFormat.AMDesignator);
            result.Add(Culture.DateTimeFormat.PMDesignator);
            return result.ToArray();
        }

        /// <summary>
        /// Return AM Indicator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>Array String with symbols AM/PM</returns>
        public static string GetAMplaceholder(CultureInfo Culture)
        {
            return Culture.DateTimeFormat.AMDesignator;
        }

        /// <summary>
        /// Return PM Indicator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>Array String with symbols AM/PM</returns>
        public static string GetPMplaceholder(CultureInfo Culture)
        {
            return Culture.DateTimeFormat.PMDesignator;
        }

        /// <summary>
        /// Return Decimal Separator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String decimal Separator</returns>
        public static string GetDecimalplaceholder(CultureInfo Culture)
        {
            return Culture.NumberFormat.NumberDecimalSeparator;
        }

        /// <summary>
        /// Return Thousands Separator according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Thousand Separator</returns>
        public static string GetThousandsplaceholder(CultureInfo Culture)
        {
            return Culture.NumberFormat.NumberGroupSeparator;
        }

        /// <summary>
        /// Return Postive Symbol according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Postive Symbol</returns>
        public static string GetPositiveSignal(CultureInfo Culture)
        {
            return Culture.NumberFormat.PositiveSign;
        }

        /// <summary>
        /// Return Negative Symbol according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Negative Symbol</returns>
        public static string GetNegativeSignal(CultureInfo Culture)
        {
            return Culture.NumberFormat.NegativeSign;
        }

        /// <summary>
        /// Return Negative Symbol according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Negative Symbol</returns>
        public static string GetPercentSymbol(CultureInfo Culture)
        {
            return Culture.NumberFormat.PercentSymbol;
        }

        /// <summary>
        /// Return Currency Symbol according to the culture
        /// </summary>
        /// <param name="Culture">CultureInfo</param>
        /// <returns>String Currency Symbol</returns>
        public static string GetCurrencySymbol(CultureInfo Culture)
        {
            return Culture.NumberFormat.CurrencySymbol;
        }
    }
}
